/******************************************************************************************************
Copyright (C) 2008 Mestrelab Research S.L. All rights reserved.

This file is part of the MNova scripting toolkit.

Authorized users of MNova Software may use this file freely, but this file is provided AS IS
with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE.
*****************************************************************************************************/

function integralTest()
{
	var spec = new NMRSpectrum( nmr.activeSpectrum() );
	//Copy spectrum integrals
	var intList = new Integrals(spec.integrals());
	print(intList);
	print(intList.count);
	print(intList.normValue);

	//Copy one integral
	var myInt = new Integral(intList.at(0));
	print(myInt);
	print(myInt.rangeMax(1));
	print(myInt.rangeMin(1));
	if( spec.dimCount > 1 )
	{
		print(myInt.rangeMax(2));
		print(myInt.rangeMin(2));
	}
	print("Integral Value "+myInt.integralValue());
	print("Normalized value "+myInt.integralValue(intList.normValue));

	//Create and add new integral
	var sReg = new SpectrumRegion(7.0, 7.5);
	var newInt = new Integral( spec, sReg, false );
	print(newInt);
	print(newInt.integralValue());
	intList.append(newInt);
	//Modify integrals normalization
	intList.normValue=newInt.integralValue();

	//Replace spectrum integrals
	spec.setIntegrals(intList);
	spec.process();
}